<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<body class="hold-transition skin-blue sidebar-mini">
<section class="content-header">
    <h1>概算成本清单查询</h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm" class="form-horizontal">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group margin-bottom-none" style="margin-right: 25px;">
                                    <label class="control-label">
                                        项目编号：
                                    </label>
                                    <label class="control-label">
                                        <input name="code" class="form-control" type="text" maxlength="255" value=""
                                               placeholder="请输入项目编号"/>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-right: 25px;">
                                    <label class="control-label">
                                        项目名称：
                                    </label>
                                    <label class="control-label">
                                        <input name="name" class="form-control" type="text" maxlength="255"
                                               placeholder="请输入项目名称"/>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-right: 25px;">
                                    <label class="control-label">
                                        需方：
                                    </label>
                                    <label class="control-label">
                                        <input name="demander" class="form-control" type="text" maxlength="255"
                                               placeholder="请输入需方"/>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-right: 25px;">
                                    <label class="control-label">
                                        安装地点：
                                    </label>
                                    <label class="control-label">
                                        <input name="address" class="form-control" type="text" maxlength="255"
                                               placeholder="请输入安装地点"/>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-right: 25px;">
                                    <label class="control-label">
                                        创建者：
                                    </label>
                                    <label class="control-label">
                                        <input name="userName" class="form-control" type="text" maxlength="255"
                                               placeholder="请输入创建者"/>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-right: 25px;">
                                    <label class="control-label">
                                        设计类别：
                                    </label>
                                    <label class="control-label">
                                        <select class="form-control" name="projectClassify">
                                            <option value="">请选择</option>
                                            <option value="1">设计</option>
                                            <option value="2">非设计</option>
                                        </select>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-right: 25px;">
                                    <label class="control-label">
                                        工作组：
                                    </label>
                                    <label class="control-label">
                                        <select class="form-control selectpicker" name="groupNameStr"
                                                data-actions-box="true" multiple onchange="changeGroupNameStrVal(this)">
                                            <option selected="selected" style="width: 200px;text-align: center"
                                                    th:each="item:${groupModelList}" th:value="${item.id}"
                                                    th:text="${item.groupName}"></option>
                                        </select>
                                        <input name="groupNameStr" type="hide" style="display: none" value=""/>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-right: 25px;">
                                    <label class="control-label">任务下达时间：</label>
                                    <label class="control-label">
                                        <input type="text" class="form-control datepicker" name="startTime"
                                               readonly="readonly"/>
                                        <span> 至 </span>
                                        <input type="text" class="form-control datepicker" name="endTime"
                                               readonly="readonly"/></label>
                                </div>
                                <button id="btn-search" type="button" class="btn btn-success pull-right">
                                    搜索
                                </button>
                            </div>
                        </div>

                    </form>
                </div>
                <div id="toolbar" class="row">
                    <!--                    <button id="btn_getData" class="btn btn-success">获取数据</button>-->
                </div>
                <div class="box-body">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
</section>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    let table;

    $(function () {
        /**
         * 加载列表
         */
        table = js.table.init({
            url: ctx + "estimateManage/queryList",
            showColumns: true,
            showExport: true,
            columns: [
                {
                    title: '序号', field: 'id', width: '60',
                    formatter: function (value, row, index, field) {
                        var pageSize = table.bootstrapTable('getOptions').pageSize;
                        var pageNumber = table.bootstrapTable('getOptions').pageNumber;
                        return pageSize * (pageNumber - 1) + index + 1;
                    }
                },
                {
                    title: '项目编号', field: 'code',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }

                    }
                },
                {
                    title: '项目名称', field: 'name',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }

                    }
                },
                {
                    title: '需方', field: 'demander',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }

                    }
                },
                {
                    title: '安装地点', field: 'address',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }
                    }
                },
                {
                    title: '项目数量', field: 'num',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }
                    }
                },
                {
                    title: '设计类别', field: 'projectClassify',
                    formatter: function (value, row, index) {
                        if (value === 1) {
                            return "设计";
                        } else if (value === 2) {
                            return "非设计";
                        }
                    }
                },
                {
                    title: '工作组', field: "groupName",
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }
                    }
                }, {
                    title: '创建者', field: "userName",
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }
                    }
                }, {
                    title: '任务下达时间', field: "createTime",
                    formatter: function (value, row, index) {
                        return value;
                    }
                },
                {
                    title: '任务开始时间', field: "createTime",
                    formatter: function (value, row, index) {
                        return value;
                    }
                },
                {
                    title: '任务完成时间', field: "createTime",
                    formatter: function (value, row, index) {
                        return value;
                    }
                },
                {
                    title: '任务状态', field: 'tstatus',
                    formatter: function (value, row, index) {
                        if (value === 1) {
                            return '<lable class="badge label-default">未开始</lable>';
                        } else if (value === 2) {
                            return '<lable class="badge label-warning">执行中</lable>';
                        }else if (value === 3) {
                            return '<lable class="badge label-success">已完成</lable>';
                        }
                    }
                },
                {
                    title: '操作', width: '180',
                    formatter: function (value, row, index) {
                        let elements = new Array();
                        if(hasP('rou:query:vew') || sessionUser.name === '管理员'){
                            elements.push('<button class="btn btn-info btn-xs" onclick="view(' + row.batId + ')">查看成本清单</button>');
                        }
                        return elements.join('');
                    }
                }

            ]
        });
        /**
         * 表格搜索
         */
        $("#btn-search").click(function () {
            js.table.search(table);
        });
    });

    /**
     * 工作组下拉框改变时修改搜索使用隐藏域的值
     * @param obj
     */
    function changeGroupNameStrVal(obj) {
        $("#queryForm [name='groupNameStr']").val($(obj).val());
    }

    /**
     * 查看成本清单
     **/
    function view(batId) {
        window.open(ctx + 'accountManage/showEstCostSheetByApproval/' + batId+'/seeQuery');
        // location.href =
    }
</script>
</body>
</html>